/**
  **************************************************************************
  * @file     at32f425_int.c
  * @brief    main interrupt service routines.
  **************************************************************************
  *                       Copyright notice & Disclaimer
  *
  * The software Board Support Package (BSP) that is made available to
  * download from Artery official website is the copyrighted work of Artery.
  * Artery authorizes customers to use, copy, and distribute the BSP
  * software and its related documentation for the purpose of design and
  * development in conjunction with Artery microcontrollers. Use of the
  * software is governed by this copyright notice and the following disclaimer.
  *
  * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  *
  **************************************************************************
  */

/* includes ------------------------------------------------------------------*/
#include "system.h"

/** @addtogroup UTILITIES_examples
  * @{
  */

/** @addtogroup FreeRTOS_demo
  * @{
  */

/**
  * @brief  this function handles nmi exception.
  * @param  none
  * @retval none
  */
void NMI_Handler(void)
{
}

/**
  * @brief  this function handles hard fault exception.
  * @param  none
  * @retval none
  */
void HardFault_Handler(void)
{
  /* go to infinite loop when hard fault exception occurs */
  while(1)
  {
  }
}

/**
  * @brief  this function handles memory manage exception.
  * @param  none
  * @retval none
  */
void MemManage_Handler(void)
{
  /* go to infinite loop when memory manage exception occurs */
  while(1)
  {
  }
}

/**
  * @brief  this function handles bus fault exception.
  * @param  none
  * @retval none
  */
void BusFault_Handler(void)
{
  /* go to infinite loop when bus fault exception occurs */
  while(1)
  {
  }
}

/**
  * @brief  this function handles usage fault exception.
  * @param  none
  * @retval none
  */
void UsageFault_Handler(void)
{
  /* go to infinite loop when usage fault exception occurs */
  while(1)
  {
  }
}

/**
  * @brief  this function handles svcall exception.
  * @param  none
  * @retval none
  */
//void SVC_Handler(void)
//{
//}

/**
  * @brief  this function handles debug monitor exception.
  * @param  none
  * @retval none
  */
void DebugMon_Handler(void)
{
}

/**
  * @brief  this function handles pendsv_handler exception.
  * @param  none
  * @retval none
  */
//void PendSV_Handler(void)
//{
//}

/**
  * @brief  this function handles systick handler.
  * @param  none
  * @retval none
  */
//void SysTick_Handler(void)
//{
//}

/**
  * @}
  */
/**
  * @brief  this function handles dma1_channel1 handler.
  * @param  none
  * @retval none
  */
void DMA1_Channel1_IRQHandler(void)
{
  if(dma_flag_get(DMA1_FDT1_FLAG) != RESET)
  {
    dma_flag_clear(DMA1_FDT1_FLAG);
		flapp_set_adc_sta(TRUE);
  }
}
/**
  * @}
  */

/**
  * @brief  this function handles usart2 handler.
  * @param  none
  * @retval none
  */
void USART2_IRQHandler(void)
{
	if(usart_flag_get(USART2, USART_RDBF_FLAG) != RESET)
	{
		/* read one byte from the receive data register */
		u8 rx_data = usart_data_receive(USART2);
		fldrv_uart_rx_int(rx_data,UART2_PORT);
	}
}

/**
  * @brief  this function handles usart1 handler.
  * @param  none
  * @retval none
  */
void USART1_IRQHandler(void)
{
    if(usart_flag_get(USART1, USART_RDBF_FLAG) != RESET)
    {
      /* read one byte from the receive data register */
      u8 rx_data = usart_data_receive(USART1);
			fldrv_uart_rx_int(rx_data,UART1_PORT);
    }
}

/**
  * @brief  this function handles usart1 handler.
  * @param  none
  * @retval none
  */

void USART4_3_IRQHandler(void)
{
	if(usart_flag_get(USART3, USART_RDBF_FLAG) != RESET)
	{
		/* read one byte from the receive data register */
		uint8_t uart3_data = usart_data_receive(USART3);
		fldrv_uart_rx_int(uart3_data,UART3_PORT);
	}
	
	if(usart_flag_get(USART4, USART_RDBF_FLAG) != RESET)
	{
		uint8_t uart4_data = usart_data_receive(USART4);
		fldrv_uart_rx_int(uart4_data,UART4_PORT);
	}
}

void TMR16_GLOBAL_IRQHandler(void)
{
	 if(tmr_flag_get(TMR16, TMR_C1_FLAG) != RESET)
  {
    tmr_flag_clear(TMR16, TMR_C1_FLAG);
		flapp_fan_speed_plus();							//风速自加
	}
}
